﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web.UI;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.DAL;
using KPIS.GERP.GIMS.MODEL;

namespace KPIS.GERP.GIMS.APP.APP_UI.Form
{
    public partial class ICM_Cal_Price_Account : System.Web.UI.Page
    {
        Common.Main cn = new Common.Main();
        D_CalPriceAccount d_cal_price_account = new D_CalPriceAccount();
        M_CalPriceAccount m_cal_price_account = new M_CalPriceAccount();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadGrid();
                btnInsert.OnClientClick = "openStautsAdd()";
            }
        }
        protected void btnInsert_Click(object sender, EventArgs e)
        {
        }
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            LoadGrid();
            grdPriceAccount.Rebind();
        }
        protected void grdPriceAccount_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            LoadGrid();
        }
        protected void grdPriceAccount_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "DataDelete")
                {
                    m_cal_price_account.icm_cal_price_account_seq = Convert.ToInt32(grdPriceAccount.Items[e.Item.ItemIndex]["icm_cal_price_account_seq"].Text);
                    m_cal_price_account.updated_by = cn.UserID;
                    m_cal_price_account.updated_when = DateTime.Now;
                    d_cal_price_account.Delete_CalPriceAccount(m_cal_price_account);
                    LoadGrid();
                    grdPriceAccount.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            
        }
        private void LoadGrid()
        {
            grdPriceAccount.DataSource = d_cal_price_account.GetList();
        }
    }
}